# -*- coding:UTF-8 -*-
from cmdb.models import EquipmentMaintLog

def equipment_maint_log(start,end):
    count=EquipmentMaintLog.objects.count()
    eRes = EquipmentMaintLog.objects.order_by('-id')[start:end]
    return {'count':count,'equipment_maint_log_list':eRes}

def add_equipment_maint_log(serial_num,maint_time,maint_man,problem,repair_time,present,pepair_man,resolution,
                            comment,operator):
    rInfo = EquipmentMaintLog(serial_num=serial_num,maint_time=maint_time,maint_man=maint_man,problem=problem,
                              repair_time=repair_time,present=present,pepair_man=pepair_man,resolution=resolution,
                              comment=comment,operator=operator)
    rInfo.save()

def get_equipment_maint_log(id):
    rInfo = EquipmentMaintLog.objects.get(id=id)
    return rInfo

def edit_equipment_maint_log(id,maint_time,maint_man,problem,repair_time,present,pepair_man,resolution,
                             comment,operator):
    eInfo = EquipmentMaintLog.objects.get(id=id)
    eInfo.problem = problem
    eInfo.maint_time = maint_time
    eInfo.maint_man = maint_man
    eInfo.repair_time = repair_time
    eInfo.present = present
    eInfo.pepair_man = pepair_man
    eInfo.resolution = resolution
    eInfo.comment = comment
    eInfo.operator = operator
    eInfo.save()